Page({
  data: {
    is_certifcation: true,
    types: [
      {
        title_name: "上传成功",
        ms_name: "我们将尽快审核你所上传的信息",
      },
      {
        title_name: "实名成功",
        ms_name: "你已完成实名信息认证",
      },
      {
        title_name: "归还信息提交成功",
        ms_name: "如约归还后，商家将会完结此订单，押金将自动解冻退还",
      },
      {
        title_name: "归还信息提交成功",
        ms_name: "如约归还后，商家将会完结此订单，押金将自动解冻退还",
      },
      {
        title_name: "还款成功!",
        ms_name: "恭喜你，本次还款已成功！",
      },
      {
        title_name: "支付成功",
        ms_name: "您已经支付成功！",
      },
      {
        title_name: "实名成功",
        ms_name: "你已完成实名信息认证！",
      },
    ],
    typesIndex: 0,
    recomend_list: [],
    scroll: false, //是否滑动页面
    loadText: "加载中...",
    page: {
      // 页面
      size: 10,
      page: 1,
      total: 0,
      pageSize: 0,
    },
  },
  onLoad(opthion) {
    my.setNavigationBar({
      frontColor: "#000000",
      backgroundColor: "#f6f6f6",
    });

    let vm = this;
    

    vm.setData({
      typesIndex: opthion.typeindex,
    });

    const { platform } = opthion
    const app = new getApp();
    if(platform) {
      app.globalData.platform = platform
    }
  },

  // onReady() {
  //   this.getRecommendGoods();
  // },

  // 获取推荐数据
  // getRecommendGoods() {
  //   let app = getApp();
  //   const { size: page_size, page } = this.data.page;
  //   my.request({
  //     url: app.globalData.testUrl + "/Api/goods/recommendGoods",
  //     data: {
  //       page_size,
  //       page,
  //     },
  //     method: "post",
  //     dataType: "json",
  //     success: (res) => {
  //       //console.log("热门推荐", res.data);
  //       if (res.data.status == "1001") {
  //         let list = [...this.data.recomend_list, ...res.data.data.data];
  //         this.setData({
  //           recomend_list: list,
  //           "page.total": res.data.data.total,
  //           "page.pageSize": Math.ceil(
  //             res.data.data.total / this.data.page.size
  //           ),
  //         });
  //       }
  //     },

  //     complete: () => {
  //       my.hideLoading(); //加载结束
  //     },
  //   });
  // },

  // 触底加载
  onReachBottom() {
    var obj = this;
    if (this.data.page.page < this.data.page.pageSize) {
      this.setData({
        scroll: true,
        page: {
          page: this.data.page.page + 1,
          size: this.data.page.size,
          total: this.data.page.total,
        },
      });

      // this.getRecommendGoods();
    } else {
      this.setData({
        scroll: true,
        loadText: "没有更多了哦",
      });

      setTimeout(function () {
        obj.setData({
          loadText: "",
          scroll: false,
        });
      }, 2000);
    }
  },

  goBack() {
    let vm = this;
    console.log(vm.data.typesIndex);
    if (vm.data.typesIndex == 0) {
      my.navigateBack({
        delta: 2,
      });
    } else if (vm.data.typesIndex == 1) {
      my.navigateBack({
        delta: 1,
      });
    } else if (vm.data.typesIndex == 2) {
      my.setStorageSync({
        //处理订单页面自动刷新缓存
        key: "isbackorder",
        data: true,
      });
      my.navigateBack({
        delta: 2,
      });
    } else if (vm.data.typesIndex == 3) {
      my.setStorageSync({
        //处理订单页面自动刷新缓存
        key: "isbackorder",
        data: true,
      });
      my.navigateBack({
        delta: 3,
      });
    } else if (vm.data.typesIndex == 4) {
      my.setStorageSync({
        //处理订单页面自动刷新缓存
        key: "isbackorder",
        data: true,
      });
      let pages = getCurrentPages(); // 当前页面
      let beforePage = pages[pages.length - 2]; // 上一页
      my.navigateBack({
        delta: 1,
        success: () => {
          beforePage.onReady();
        },
      });
    } else if (vm.data.typesIndex == 5) {
      my.setStorageSync({
        //处理订单页面自动刷新缓存
        key: "isbackorder",
        data: true,
      });
      // my.navigateBack({
      //   delta: 3
      // });
      my.navigateTo({
        url: "../myorders/myorders?id=3",
      });
    } else if (vm.data.typesIndex == 6) {
      //确认订单页面 实名认证
      my.navigateBack({
        delta: 2,
      });
    }
  },
});
